/********************************************************************
	created:	2008/12/21
	created:	21:12:2008   22:55
	filename: 	g:\Projects On Develop\board-game\protype\BattleLine\BattleLine\BattleLineChessmanManager.cpp
	file path:	g:\Projects On Develop\board-game\protype\BattleLine\BattleLine
	file base:	BattleLineChessmanManager
	file ext:	cpp
	author:		Ray Xi
	
	purpose:	Manage chessman
*********************************************************************/
#include "StdAfx.h"
#include "BattleLineChessmanManager.h"

CBattleLineChessmanManager::CBattleLineChessmanManager(void)
{
}

CBattleLineChessmanManager::~CBattleLineChessmanManager(void)
{
}

void CBattleLineChessmanManager::Init(int numChessman)
{
	CGameEntityAsset::Init();

	m_iNumChessman = numChessman;
	CBattleLineChessman* pChessman;
	for(int i = 0;i < numChessman;i++)
	{
		pChessman = new CBattleLineChessman;
		m_oGameEntityList.push_back(pChessman);
	}
	
	for(vector<CGameEntity*>::iterator it = m_oGameEntityList.begin();it != m_oGameEntityList.end();it++)
	{
		(*it)->Init();
	}
}

void CBattleLineChessmanManager::Update(float fTime)
{
	CGameEntityAsset::Update(fTime);

	for(vector<CGameEntity*>::iterator it = m_oGameEntityList.begin();it != m_oGameEntityList.end();it++)
	{
		(*it)->Update(fTime);
	}
}

void CBattleLineChessmanManager::Render()
{
	CGameEntityAsset::Render();

	for(vector<CGameEntity*>::iterator it = m_oGameEntityList.begin();it != m_oGameEntityList.end();it++)
	{
		(*it)->Render();
	}
}

void CBattleLineChessmanManager::Deinit()
{
	for(vector<CGameEntity*>::iterator it = m_oGameEntityList.begin();it != m_oGameEntityList.end();it++)
	{
		(*it)->Deinit();
		delete (*it);
	}
	m_oGameEntityList.clear();

	CGameEntityAsset::Deinit();
}